package com.ddf.publics.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.io.Serializable;

/**
 * 用户表(User)实体类
 *
 * @author norman
 * @since 2020-06-19 08:14:59
 */
public class User implements Serializable, UserDetails {
    private static final long serialVersionUID = 936036524907719170L;
    /**
     * 主键
     * */    
    private Integer id;
    /**
     * 手机号
     * */    
    private String phone;
    /**
     * 邮箱
     * */    
    private String email;
    /**
     * 头像
     * */    
    private String face;
    /**
     * 昵称
     * */    
    private String nickName;
    /**
     * 性别
     * */    
    private String sex;
    /**
     * qq登录的唯一识别码
     * */    
    private String openId;
    /**
     * 注册时间
     * */    
    private Date registerTime;
    /**
     * 登录密码
     * */    
    private String password;
    /**
     * 信用分
     * */    
    private Integer credit;
    /**
     * 用户剩余积分
     * */    
    private Integer residuePoint;
    /**
     * 邀请码
     * */    
    private String inviteNum;

    public User() {}

    public User(Integer id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", phone='" + phone + '\'' +
                ", email='" + email + '\'' +
                ", face='" + face + '\'' +
                ", nickName='" + nickName + '\'' +
                ", sex='" + sex + '\'' +
                ", openId='" + openId + '\'' +
                ", registerTime=" + registerTime +
                ", password='" + password + '\'' +
                ", credit=" + credit +
                ", residuePoint=" + residuePoint +
                ", inviteNum='" + inviteNum + '\'' +
                '}';
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return new ArrayList<>();
    }

    @Override
    public String getUsername() {
        return this.phone;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFace() {
        return face;
    }

    public void setFace(String face) {
        this.face = face;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public Date getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getCredit() {
        return credit;
    }

    public void setCredit(Integer credit) {
        this.credit = credit;
    }

    public Integer getResiduePoint() {
        return residuePoint;
    }

    public void setResiduePoint(Integer residuePoint) {
        this.residuePoint = residuePoint;
    }

    public String getInviteNum() {
        return inviteNum;
    }

    public void setInviteNum(String inviteNum) {
        this.inviteNum = inviteNum;
    }

}